<?php
/*
 * @Author: lokei
 * @Date: 2023-03-25 08:34:03
 * @LastEditors: lokei
 * @LastEditTime: 2023-06-03 14:50:08
 * @Description: 
 */

namespace App\Http\Controllers\Store\Audit;

use App\Common\Tools\ResultTool;
use App\Http\Controllers\Controller;
use App\Models\Store\StoreModel;
use Illuminate\Http\Request;

class AuditController extends Controller {
    public function get(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $res = ResultTool::success();
        $res['data']['status'] = $store->status;
        $res['data']['business_status'] = $store->business_status;
        $res['data']['reject_reason'] = $store->reject_reason;
        return $res;
    }

    public function set(Request $request) {
        $store = StoreModel::where('id', '=', $request->input('store_id'))->first();
        $store->status = $request->input('status');
        $store->business_status = $request->input('business_status');
        if($request->input('status') == '2') {
            $store->reject_reason = $request->input('reject_reason');
        }
        $store->save();
        $res = ResultTool::success();
        return $res;
    }
}